import java.util.Scanner;

public class test1 {
//模拟登录，输入三次密码，三次以上则提示输入结束
    /*public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        for (int i = 0; i < 3; i++) {
            String password = "12345";
            System.out.println("请输入密码");
            String n = scanner.nextLine();
            if(n == password){
                System.out.println("密码正确,登录成功");
            }
            else{
                count++;
                if(count < 3){
                    System.out.println("密码错误，请重新输入，你还有" + (3 - count) + "次尝试机会");
                }
            }

        }
        if (count == 3){
            System.out.println("三次密码都输入错误，退出程序");
        }
    }*/
//AI改进
       /* public static void main(String[] args) {
            String correctPassword = "123456";//使用字符串输入密码，可以更多样密码
            int attemptCount = 0;//增加一个变量，可以用于密码输入错误时提示剩余次数
            Scanner scanner = new Scanner(System.in);

            while (attemptCount < 3) {
                System.out.print("请输入密码: ");
                String inputPassword = scanner.nextLine();
                if (inputPassword.equals(correctPassword)) {//这行代码用于比较输入的字符串和和预设字符串的比较
                    System.out.println("登录成功");
                    break;
                } else {
                    attemptCount++;
                    if (attemptCount < 3) {
                        System.out.println("密码错误，请重新输入。你还有 " + (3 - attemptCount) + " 次尝试机会。");
                    }
                }
            }

            if (attemptCount == 3) {
                System.out.println("三次密码均错误，退出程序");
            }

            // 关闭 Scanner 对象
            scanner.close();
        }*/

    //求两个整数的最大公约数
    /*public static int god(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    public static void main(String[] args) {
        int num1 = 48;
        int num2 = 18;
        int result = god(num1, num2);
        System.out.println(num1 + " 和 " + num2 + " 的最大公约数是: " + result);
    }*/
//求两个数最大值，再求三个数的最大值
/*public static void main(String[] args) {
    int a = 15;
    int b = 25;
    int c = 100;
    System.out.println(max2(a, b));
    System.out.println(max3(a, b, c));
}
public static int max2(int a ,int b){
    int temp;
    if(a < b){
        temp = a;
        a = b;
        b = temp;

    }
    return a;
}
    public static int max3(int a ,int b , int c) {
    int d = max2(a , b);
    int e = max2(b , c);
    int f = max2(d , e);
    return f;

    }*/
//求n的阶乘
/*public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println("请输入一个数");
    int n = scanner.nextInt();
    System.out.println(fac(n));
}
public static int fac(int n){
    int sum = 1;
    for (int i = 1; i <= n; i++) {
        sum *= i;
    }
    return sum;
}*/
//阶乘的和
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数");
        int n = scanner.nextInt();
        System.out.println(fac(n));
    }

    public static int fac(int n) {
        int fac = 1;
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                fac *= i;
            }
            sum += fac;
        }
        return sum;
    }
}



